package com.lz.action;

import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import com.lz.form.UploadItemDTO;
import com.lz.service.UploadItemService;

public class NextPageAction extends DispatchAction {

    String filePath = "";

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
       HttpSession session=request.getSession(true);
       UploadItemDTO uform = (UploadItemDTO)session.getAttribute("queryparams");
        int pageNumber=Integer.parseInt(request.getParameter("pagenumber"));
        int start=pageNumber*AdminSearchAction.DISPLAYCOUNT;
        
        ArrayList list = UploadItemService.getSearchResult(uform,uform.getOrderby(),""+start,""+AdminSearchAction.DISPLAYCOUNT);
        uform.setShopid("1");
        uform.setImageList(list);
        pageNumber++;
        request.setAttribute("pagenumber",""+pageNumber);
        session.setAttribute("queryparams",uform);
       
        if(list.size()==0){
        	request.setAttribute("message","No More records");
        	return mapping.findForward("MESSAGE");
        }
              
        return mapping.findForward(uform.getForward());
    }

}
